<template>
    <div>
        <Row class="button_row">
            <span style="float: left;">
                 <Button type="primary" icon="ios-add" @click="handleAdd">新增</Button>
            </span>
        </Row>
        <div class="table_div">
            <Table :columns="columns" :data="tableData" :loading="Loading">
                <template slot-scope="{row}" slot="action">
                    <Button type="info" size="small" style="margin-right: 5px" @click="handleEdit(row)">编辑</Button>
                    <Button type="success" size="small" style="margin-right: 5px" @click="handleDetail(row)">详情
                    </Button>
                    <Button type="error" size="small" style="margin-right: 5px" @click="handleDelete(row.id)">删除
                    </Button>
                </template>
                <template slot-scope="{row}" slot="condition">
                    <Button type="info" size="small" style="margin-right: 5px" @click="handleConditionEdit(row)">编辑
                    </Button>
                </template>
                <template slot-scope="{row}" slot="property">
                    <Button type="info" size="small" style="margin-right: 5px" @click="handlePropertyEdit(row)">编辑
                    </Button>
                </template>
            </Table>
            <Page :total="dataCount" :page-size="pageSize" show-total class="paging"
                  @on-change="handleTableChange" :current="pageNo"></Page>
        </div>
        <rule-infor-modal ref="modalForm" @ok="modalFormOk"/>
        <rule-info-condition-modal ref="modalConditionForm" @ok="modalFormOk"/>
        <rule-info-property-modal ref="modalPropertyForm" @ok="modalFormOk"/>
    </div>
</template>

<script>
    import {CommonMixin} from '@/views/common/js/CommonMixin'
    import {getAction, postAction} from '@/api/request'
    import RuleInforModal from './modules/RuleInforModal'
    import RuleInfoConditionModal from './modules/RuleInfoConditionModal'
    import RuleInfoPropertyModal from './modules/RuleInfoPropertyModal'


    export default {
        mixins: [CommonMixin],
        components: {RuleInforModal, RuleInfoConditionModal, RuleInfoPropertyModal},
        data() {
            return {
                columns: [
                    {
                        title: '名称',
                        key: 'ruleName'
                    },
                    {
                        title: '描述',
                        key: 'ruleDesc',
                    },
                    {
                        title: '字典信息',
                        key: 'ruleDictType',
                    },
                    {
                        title: '备注',
                        key: 'remarks',
                    },
                    {
                        title: '操作',
                        key: 'action',
                        align: 'center',
                        slot: 'action',
                    },
                    {
                        title: '条件操作',
                        key: 'condition',
                        align: 'center',
                        slot: 'condition',
                    },
                    {
                        title: '属性操作',
                        key: 'property',
                        align: 'center',
                        slot: 'property',
                    },

                ],
                queryParam: {},
                Loading: true,
                url: {
                    list: "/api/ac/subsistence/RuleInforService/page",
                    delete: "/api/ac/subsistence/RuleInforService/delete"
                },
            }
        },
        methods: {
            handleConditionEdit(row) {
                this.$refs.modalConditionForm.edit(row);
                this.$refs.modalConditionForm.title = "条件编辑";
                this.$refs.modalConditionForm.disableSubmit = false;
                this.$refs.modalConditionForm.key = this.uuid();
            },
            handlePropertyEdit(row) {
                this.$refs.modalPropertyForm.edit(row);
                this.$refs.modalPropertyForm.title = "属性编辑";
                this.$refs.modalPropertyForm.disableSubmit = false;
                this.$refs.modalPropertyForm.key = this.uuid();
            }
        },
        created() {
            this.loadData();
        },
    }
</script>
<style scoped>
    .paging {
        float: right;
        margin-top: 10px;
    }

    /deep/ .ivu-upload-list {
        display: none;
    }

    /deep/ .ivu-table-cell {
        padding-right: 0px;

    }
</style>